#pragma once

#include <stdexcept>

#include "Config.h"

class CException : public std::runtime_error
{
  PyObject *m_exc;

  static void Translator(const CException& ex);
public:
  CException(PyObject *exc, const std::string& msg)
    : std::runtime_error(msg), m_exc(exc)
  {

  }

  static void Expose(void);
};

#define DEFINE_ERROR(name, exc) struct name : public CException { name(const std::string& msg) : CException(exc, msg) {} };

DEFINE_ERROR(IndexError, ::PyExc_IndexError)
DEFINE_ERROR(KeyError, ::PyExc_KeyError)